import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    userInfo: {},
    token: "" || localStorage.getItem("token"),
    showDrawer: false
  },
  mutations: {
    setToken(state, token) {
      console.log("set token", token);
      state.token = token;
      localStorage.setItem("token", token);
    },
    delToken(state) {
      state.token = "";
      localStorage.removeItem("token");
    },
    setUserInfo(state, userName) {
      state.userName = userName;
    },
    showDrawer(state) {
      state.showDrawer = !state.showDrawer;
    }
  },
  actions: {
    logOut() {
      // this.$store.dispatch('LogOut').then(() => {
      //   //跳转到登录页面
      //   this.$router.push('/login');
      // });
    }
  },
  modules: {}
});
